import request from '@/utils/axiosRequest.js'


// 模糊查询
export function searchStudents(studentNo, name, pageNo, pageSize){
  let url = "/system/student/search?studentNo=";
  url = url + (studentNo ? studentNo : "");
  url = url + "&name=" + (name ? name : "");
  url = url + "&pageNo=" + (pageNo ? pageNo : "1");
  url = url + "&pageSize=" + (pageSize ? pageSize : "10");
  return request({
    url: url,
    method: "get"
  })
}

// 添加
export function addStudent(student) {
  return request({
    url: "/system/student",
    method: "post",
    data: student
  })
}

// 更新
export function updateStudent(student) {
  return request({
    url: "/system/student",
    method: "put",
    data: student
  })
}

// 账号激活、冻结
export function updateStudentStatus(studentId) {
  return request({
    url: "/system/student/status/" + studentId,
    method: "put"
  })
}

// 批量删除
export function deleteStudents(studentIdList) {
  return request({
    url: "/system/student/batch",
    method: "delete",
    data: studentIdList
  })
}

// 寝室成员
export function getMembersOfAddress(addressId) {
  return request({
    url: "system/student/address/member/" + addressId,
    method: "get"
  })
}

// 重置密码
export function resetPassword(studentId){
  return request({
    url: "system/student/password/reset/" + studentId,
    method: "put"
  })
}

// 重置学生寝室(或移除寝室)
export function removeAddressOfStudent(studentId) {
  return request({
    url: "/system/student/address/" + studentId,
    method: "delete"
  })
}

